<template lang="pug">
    .home
        h1 首页
        .draw-chart
            div#myChart1().my-chart
            div#myChart2().my-chart
            div#myChart3().my-chart
        h3 我是内容
        h3 我是内容
        h3 我是内容
        h3 我是内容

</template>

<script>
export default {
  name: "home",
  data() {
    return {};
  },
  mounted() {
    this.$nextTick(function() {
      // 画charts
      this.drawChart();
    });
  },
  methods: {
    // 画charts
    drawChart() {
      // 基于准备好的dom，初始化 Easy charts实例
      const myChart1 = this.$echarts.init(document.getElementById("myChart1"));
      const myChart2 = this.$echarts.init(document.getElementById("myChart2"));
      const myChart3 = this.$echarts.init(document.getElementById("myChart3"));
      // 绘制图表1
      myChart1.setOption({
        title: {
          text: "line"
        },
        xAxis: {
          type: "category",
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
        },
        yAxis: {
          type: "value"
        },
        series: [
          {
            data: [100, 100, 100, 100, 200, 100, 100],
            type: "line"
          }
        ]
      });
      // 绘制图表
      myChart2.setOption({
        title: {
          text: "bar展示"
        },
        xAxis: {
          type: "category",
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
        },
        yAxis: {
          type: "value"
        },
        series: [
          {
            data: [120, 200, 150, 80, 70, 110, 130],
            type: "bar"
          }
        ]
      });
      // 绘制图表
      myChart3.setOption({
        title: {
          text: "pie",
          subtext: "纯属虚构",
          x: "center"
        },
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
          orient: "vertical",
          left: "left",
          data: ["直接访问", "邮件营销", "联盟广告", "视频广告", "搜索引擎"]
        },
        series: [
          {
            name: "访问来源",
            type: "pie",
            radius: "55%",
            center: ["50%", "60%"],
            data: [
              { value: 335, name: "直接访问" },
              { value: 310, name: "邮件营销" },
              { value: 234, name: "联盟广告" },
              { value: 135, name: "视频广告" },
              { value: 1548, name: "搜索引擎" }
            ],
            itemStyle: {
              emphasis: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)"
              }
            }
          }
        ]
      });
    }
  },
  components: {}
};
</script>

<style scoped lang="stylus">
    .home
        padding 30px
        .draw-chart
            display flex
            flex-wrap  wrap
            justify-content space-between
            .my-chart
                width: 600px
                height 600px
                display inline-block
                background-color white
                box-shadow 1px 1px 5px gray
                margin 80px
</style>
